package com.leyou.trade.utils;

import com.leyou.auth.dto.UserDetail;
import com.leyou.auth.utils.UserContext;

public class CollectionNameBuilder {

    private final String namePrefix;
    public CollectionNameBuilder(String namePrefix){
        this.namePrefix=namePrefix+"_";
    }

    public String builder(){
        UserDetail user= UserContext.getUser();
        if (user==null){
            return "";
        }
        //用一个固定的collection前缀 凭借一个用户id作为用户的collection
        return namePrefix+user.getId().hashCode()%100;
    }

}
